<?php
include('inc_head.php');
$uid=$wu->request_string('uid');
$data=to_array_keys('Name','MobileNumber','Remark');
if($uid){
	$data=$db->fetch_row(sprintf("select * from tusermember where UserName = '%s'",$uid));	
}
if($wu->request_string("act")=='save'){
	$m=new module('tusermember');
	$dm->param('Name','string');
	$dm->param('MobileNumber','string');
	$dm->param('Remark','string');
	if($uid){
		$wu->redirect($this->dm->update(sprintf("UserName='%s'",$uid))?'编辑成功':'编辑失败：'.$this->dm->get_error(),'member_list.php');
	}else{
		$dm->param('UserName','string','登录名未填写');
		$dm->param('Password','string','密码未填写');
		$wu->redirect($this->dm->insert()?'新增成功':'新增失败'.$this->dm->get_error(),'member_list.php');
	}
}
?>
<form action="#" method="post" >
    <h1>编辑用户</h1>
<table cellpadding="0" cellspacing="0">登录名</td><td><?php echo $uid?$uid:'<input type="text" name="UserName" />'; ?></td></tr>
        <?php
		if(!$uid){
		?>
        <tr><td>密码</td><td><input type="text" name="Password"  /></td></tr>
        <?php } ?>
        <tr><td>姓名</td><td><input type="text" name="Name" size="12" value="<?php echo $data['Name']; ?>" /></td></tr>
        <tr><td>手机号码</td><td><input type="text" name="MobileNumber" size="12" value="<?php echo $data['MobileNumber']; ?>" /></td></tr>
        <tr><td>备注</td><td><textarea name="Remark" cols="120" rows="15"><?php echo $data['Remark']; ?></textarea></td></tr>
        <tr><td>
                <input type="submit" value="保存" />
                <input type="reset" class="btn" value="重置" />
            	<input type="hidden" name="act" value="save" />
            </td></tr>
    </fieldset>
</form>
<?php
	include('inc_foot.php');
?>